import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:portal_website/tool/image_network.dart';

void main() {
  runApp(const InnovationServicePlatform());
}

// 主应用程序
class InnovationServicePlatform extends StatelessWidget {
  const InnovationServicePlatform({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '创新服务平台',
      theme: ThemeData(
        primaryColor: const Color(0xFF1E5799),
        secondaryHeaderColor: const Color(0xFF207CCA),
        scaffoldBackgroundColor: const Color(0xFFF5F9FF),
        textTheme: const TextTheme(
          bodyLarge:
              TextStyle(color: Color(0xFF555555), fontSize: 16, height: 1.8),
          bodyMedium: TextStyle(color: Color(0xFF666666), fontSize: 14),
          titleLarge: TextStyle(
            color: Color(0xFF1E5799),
            fontSize: 28,
            fontWeight: FontWeight.bold,
          ),
          titleMedium: TextStyle(
            color: Color(0xFF1E5799),
            fontSize: 20,
            fontWeight: FontWeight.bold,
          ),
          titleSmall: TextStyle(
            color: Color(0xFF1E5799),
            fontSize: 18,
            fontWeight: FontWeight.bold,
          ),
        ),
        fontFamily: 'Microsoft YaHei',
      ),
      initialRoute: '/',
      routes: {
        '/': (context) => const HomePage(),
        '/intelligent-calculation': (context) =>
            const IntelligentCalculationCenter(),
        '/knowledge': (context) => const KnowledgeCenter(),
        '/model': (context) => const ModelCenter(),
        '/scenario': (context) => const ScenarioApplicationCenter(),
      },
    );
  }
}

// 首页
class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            const Header(),
            Container(
              padding: const EdgeInsets.all(20),
              child: Column(
                children: [
                  const Breadcrumb(currentPage: '首页'),
                  const SizedBox(height: 20),
                  const Center(
                    child: Text(
                      '创新服务平台',
                      style: TextStyle(
                        fontSize: 32,
                        color: Color(0xFF1E5799),
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ),
                  const SizedBox(height: 30),
                  GridView.count(
                    shrinkWrap: true,
                    physics: const NeverScrollableScrollPhysics(),
                    crossAxisCount:
                        MediaQuery.of(context).size.width < 768 ? 1 : 2,
                    crossAxisSpacing: 20,
                    mainAxisSpacing: 20,
                    childAspectRatio: 1.5,
                    children: [
                      _buildCenterCard(
                        context,
                        title: '智算中心',
                        description: '提供强大的计算资源和智能分析能力',
                        icon: Icons.supervisor_account,
                        route: '/intelligent-calculation',
                      ),
                      _buildCenterCard(
                        context,
                        title: '知识中枢',
                        description: '整合各类知识资源，提供全面的信息服务',
                        icon: Icons.library_books,
                        route: '/knowledge',
                      ),
                      _buildCenterCard(
                        context,
                        title: '模型中枢',
                        description: '集中管理各类AI模型，支持训练和推理',
                        icon: Icons.model_training,
                        route: '/model',
                      ),
                      _buildCenterCard(
                        context,
                        title: '场景应用中心',
                        description: '展示和推广各类数字化转型应用场景',
                        icon: Icons.apps,
                        route: '/scenario',
                      ),
                    ],
                  ),
                ],
              ),
            ),
            const Footer(),
          ],
        ),
      ),
    );
  }

  Widget _buildCenterCard(
    BuildContext context, {
    required String title,
    required String description,
    required IconData icon,
    required String route,
  }) {
    return Card(
      elevation: 5,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(8),
      ),
      color: Colors.white,
      child: InkWell(
        onTap: () => Navigator.pushNamed(context, route),
        borderRadius: BorderRadius.circular(8),
        child: Padding(
          padding: const EdgeInsets.all(20),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(icon, size: 48, color: const Color(0xFF207CCA)),
              const SizedBox(height: 15),
              Text(
                title,
                style: Theme.of(context).textTheme.titleMedium,
              ),
              const SizedBox(height: 10),
              Text(
                description,
                style: Theme.of(context).textTheme.bodyMedium,
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      ),
    );
  }
}

// 智算中心页面
class IntelligentCalculationCenter extends StatefulWidget {
  const IntelligentCalculationCenter({super.key});

  @override
  State<IntelligentCalculationCenter> createState() =>
      _IntelligentCalculationCenterState();
}

class _IntelligentCalculationCenterState
    extends State<IntelligentCalculationCenter> {
  String activeSection = 'home';

  final List<Map<String, String>> menuItems = [
    {'id': 'home', 'name': '首页'},
    {'id': 'construction', 'name': '建设概况'},
    {'id': 'policy', 'name': '政策资讯'},
    {'id': 'activity', 'name': '活动报道'},
    {'id': 'service', 'name': '服务介绍'},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            const Header(),
            Container(
              padding: const EdgeInsets.all(20),
              child: Column(
                children: [
                  const Breadcrumb(
                    path: ['服务平台', '智算中心'],
                    currentPage: '智算中心',
                  ),
                  const SizedBox(height: 20),
                  LayoutBuilder(
                    builder: (context, constraints) {
                      if (constraints.maxWidth < 768) {
                        return Column(
                          children: [
                            _buildMobileMenu(),
                            const SizedBox(height: 20),
                            _buildContent(),
                          ],
                        );
                      } else {
                        return Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            _buildSidebar(),
                            const SizedBox(width: 30),
                            Expanded(child: _buildContent()),
                          ],
                        );
                      }
                    },
                  ),
                ],
              ),
            ),
            const Footer(
              copyright: '© 2025 创新服务平台智算中心 版权所有',
              email: 'hpc@innovationservice.com',
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildSidebar() {
    return Container(
      width: 250,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '智算中心',
            style: Theme.of(context).textTheme.titleSmall,
          ),
          const SizedBox(height: 20),
          Column(
            children: menuItems.map((item) {
              return Padding(
                padding: const EdgeInsets.only(bottom: 15),
                child: InkWell(
                  onTap: () => setState(() => activeSection = item['id']!),
                  borderRadius: BorderRadius.circular(4),
                  child: Container(
                    padding:
                        const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                    decoration: BoxDecoration(
                      color: activeSection == item['id']
                          ? const Color(0xFFF0F7FF)
                          : Colors.transparent,
                      borderRadius: BorderRadius.circular(4),
                      border: activeSection == item['id']
                          ? const Border(
                              left: BorderSide(
                                  color: Color(0xFF207CCA), width: 4))
                          : null,
                    ),
                    child: Text(
                      item['name']!,
                      style: TextStyle(
                        color: activeSection == item['id']
                            ? const Color(0xFF1E5799)
                            : const Color(0xFF555555),
                        fontWeight: activeSection == item['id']
                            ? FontWeight.bold
                            : FontWeight.normal,
                      ),
                    ),
                  ),
                ),
              );
            }).toList(),
          ),
        ],
      ),
    );
  }

  Widget _buildMobileMenu() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(10),
      child: SingleChildScrollView(
        scrollDirection: Axis.horizontal,
        child: Row(
          children: menuItems.map((item) {
            return Padding(
              padding: const EdgeInsets.symmetric(horizontal: 10),
              child: InkWell(
                onTap: () => setState(() => activeSection = item['id']!),
                borderRadius: BorderRadius.circular(4),
                child: Container(
                  padding:
                      const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                  decoration: BoxDecoration(
                    color: activeSection == item['id']
                        ? const Color(0xFFF0F7FF)
                        : Colors.transparent,
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: Text(
                    item['name']!,
                    style: TextStyle(
                      color: activeSection == item['id']
                          ? const Color(0xFF1E5799)
                          : const Color(0xFF555555),
                      fontWeight: activeSection == item['id']
                          ? FontWeight.bold
                          : FontWeight.normal,
                    ),
                  ),
                ),
              ),
            );
          }).toList(),
        ),
      ),
    );
  }

  Widget _buildContent() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(30),
      child: _getSectionContent(activeSection),
    );
  }

  Widget _getSectionContent(String sectionId) {
    switch (sectionId) {
      case 'home':
        return const HomeSection(
          title: '智算中心',
          subtitle: '提供高性能计算资源和智能分析服务',
          introText:
              '智算中心是创新服务平台的核心组成部分，致力于为各类机构和企业提供强大的计算能力和智能分析服务。我们拥有先进的硬件设施和专业的技术团队，能够满足不同行业的计算需求，推动科技创新和产业升级。',
          features: [
            {'title': '高性能计算', 'description': '提供大规模并行计算能力，支持复杂科学计算和工程模拟'},
            {'title': '智能数据分析', 'description': '整合机器学习技术，提供高效的数据处理和分析服务'},
            {'title': '弹性资源调度', 'description': '根据需求动态调整计算资源，提高资源利用率'},
            {'title': '安全可靠', 'description': '多层次安全保障，确保数据和计算过程的安全性'},
            {'title': '专业技术支持', 'description': '拥有经验丰富的技术团队，提供全方位的技术支持'},
            {'title': '易用性强', 'description': '提供友好的用户界面和完善的API，降低使用门槛'},
          ],
          news: [
            {
              'date': '2025-03-15',
              'title': '智算中心完成新一轮硬件升级',
              'content': '本次升级将计算能力提升50%，能够更好地满足人工智能训练和大规模数据处理需求。',
            },
            {
              'date': '2025-02-28',
              'title': '我省首个AI计算集群在智算中心正式启用',
              'content': '该集群将为省内企业和科研机构提供强大的AI模型训练和推理能力，推动AI技术应用落地。',
            },
            {
              'date': '2025-01-10',
              'title': '智算中心与多家高校达成战略合作',
              'content': '合作将围绕人才培养、科研创新等方面展开，共同推动高性能计算技术的发展和应用。',
            },
          ],
        );
      case 'service':
        return const ServiceSection(
          title: '服务介绍',
          services: [
            {
              'title': '高性能计算服务',
              'image': '',
              'description':
                  '提供大规模并行计算资源，支持科学计算、工程模拟、数据分析等各类计算密集型任务。配备先进的GPU和CPU集群，满足不同场景的计算需求。',
              'features': '服务特点：高算力、高可靠性、灵活调度、按需计费',
              'scenarios': '适用场景：科学研究、工程设计、气象预报、人工智能训练等',
            },
            {
              'title': '数据存储与管理服务',
              'image': '',
              'description':
                  '提供安全可靠的数据存储解决方案，支持海量数据的存储、备份和管理。采用分布式存储架构，确保数据的高可用性和安全性。',
              'features': '服务特点：大容量、高可靠、安全加密、弹性扩展',
              'scenarios': '适用场景：数据备份、海量数据存储、数据共享与协作等',
            },
            {
              'title': '技术咨询与支持服务',
              'image': '',
              'description':
                  '由专业技术团队提供一对一的技术咨询和支持，帮助用户解决计算过程中遇到的各类问题，优化计算方案，提高计算效率。',
              'features': '服务特点：专业团队、快速响应、定制化方案、全程跟踪',
              'scenarios': '适用场景：计算方案设计、性能优化、技术难题解决等',
            },
          ],
        );
      default:
        return _buildDefaultSection(sectionId);
    }
  }

  Widget _buildDefaultSection(String sectionName) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          sectionName == 'construction'
              ? '建设概况'
              : sectionName == 'policy'
                  ? '政策资讯'
                  : '活动报道',
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 20),
        const Text(
          '该栏目正在建设中，敬请期待...',
          style: TextStyle(fontSize: 16, color: Color(0xFF666666)),
        ),
      ],
    );
  }
}

// 知识中枢页面
class KnowledgeCenter extends StatefulWidget {
  const KnowledgeCenter({super.key});

  @override
  State<KnowledgeCenter> createState() => _KnowledgeCenterState();
}

class _KnowledgeCenterState extends State<KnowledgeCenter> {
  String activeSection = 'home';

  final List<Map<String, String>> menuItems = [
    {'id': 'home', 'name': '首页'},
    {'id': 'construction', 'name': '建设概况'},
    {'id': 'policy', 'name': '政策资讯'},
    {'id': 'resource', 'name': '知识资源'},
    {'id': 'service', 'name': '服务介绍'},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            const Header(),
            Container(
              padding: const EdgeInsets.all(20),
              child: Column(
                children: [
                  const Breadcrumb(
                    path: ['服务平台', '知识中枢'],
                    currentPage: '知识中枢',
                  ),
                  const SizedBox(height: 20),
                  LayoutBuilder(
                    builder: (context, constraints) {
                      if (constraints.maxWidth < 768) {
                        return Column(
                          children: [
                            _buildMobileMenu(),
                            const SizedBox(height: 20),
                            _buildContent(),
                          ],
                        );
                      } else {
                        return Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            _buildSidebar(),
                            const SizedBox(width: 30),
                            Expanded(child: _buildContent()),
                          ],
                        );
                      }
                    },
                  ),
                ],
              ),
            ),
            const Footer(
              copyright: '© 2025 创新服务平台知识中枢 版权所有',
              email: 'knowledge@innovationservice.com',
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildSidebar() {
    return Container(
      width: 250,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '知识中枢',
            style: Theme.of(context).textTheme.titleSmall,
          ),
          const SizedBox(height: 20),
          Column(
            children: menuItems.map((item) {
              return Padding(
                padding: const EdgeInsets.only(bottom: 15),
                child: InkWell(
                  onTap: () => setState(() => activeSection = item['id']!),
                  borderRadius: BorderRadius.circular(4),
                  child: Container(
                    padding:
                        const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                    decoration: BoxDecoration(
                      color: activeSection == item['id']
                          ? const Color(0xFFF0F7FF)
                          : Colors.transparent,
                      borderRadius: BorderRadius.circular(4),
                      border: activeSection == item['id']
                          ? const Border(
                              left: BorderSide(
                                  color: Color(0xFF207CCA), width: 4))
                          : null,
                    ),
                    child: Text(
                      item['name']!,
                      style: TextStyle(
                        color: activeSection == item['id']
                            ? const Color(0xFF1E5799)
                            : const Color(0xFF555555),
                        fontWeight: activeSection == item['id']
                            ? FontWeight.bold
                            : FontWeight.normal,
                      ),
                    ),
                  ),
                ),
              );
            }).toList(),
          ),
        ],
      ),
    );
  }

  Widget _buildMobileMenu() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(10),
      child: SingleChildScrollView(
        scrollDirection: Axis.horizontal,
        child: Row(
          children: menuItems.map((item) {
            return Padding(
              padding: const EdgeInsets.symmetric(horizontal: 10),
              child: InkWell(
                onTap: () => setState(() => activeSection = item['id']!),
                borderRadius: BorderRadius.circular(4),
                child: Container(
                  padding:
                      const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                  decoration: BoxDecoration(
                    color: activeSection == item['id']
                        ? const Color(0xFFF0F7FF)
                        : Colors.transparent,
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: Text(
                    item['name']!,
                    style: TextStyle(
                      color: activeSection == item['id']
                          ? const Color(0xFF1E5799)
                          : const Color(0xFF555555),
                      fontWeight: activeSection == item['id']
                          ? FontWeight.bold
                          : FontWeight.normal,
                    ),
                  ),
                ),
              ),
            );
          }).toList(),
        ),
      ),
    );
  }

  Widget _buildContent() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(30),
      child: _getSectionContent(activeSection),
    );
  }

  Widget _getSectionContent(String sectionId) {
    switch (sectionId) {
      case 'home':
        return const HomeSection(
          title: '知识中枢',
          subtitle: '整合优质知识资源，助力创新发展',
          introText:
              '知识中枢是集知识资源整合、共享、传播于一体的综合性服务平台。我们汇聚了各行各业的专业知识、技术文档、研究成果等资源，通过智能化的管理和推荐机制，为用户提供精准、高效的知识服务，促进知识的传播与创新应用。',
          features: [
            {'title': '知识资源整合', 'description': '汇聚多领域知识资源，构建全面的知识体系'},
            {'title': '智能检索', 'description': '采用先进的搜索引擎技术，快速精准定位所需知识'},
            {'title': '个性化推荐', 'description': '基于用户需求和行为，提供个性化知识推荐服务'},
            {'title': '知识共享', 'description': '构建知识共享社区，促进用户间的知识交流与合作'},
            {'title': '更新及时', 'description': '定期更新知识内容，确保信息的时效性和准确性'},
            {'title': '多终端访问', 'description': '支持电脑、手机等多种终端访问，随时随地获取知识'},
          ],
          news: [
            {
              'date': '2025-03-10',
              'title': '知识中枢新增10万份行业研究报告',
              'content': '涵盖人工智能、新能源、生物医药等多个热门领域，为用户提供更丰富的研究资源。',
            },
            {
              'date': '2025-02-20',
              'title': '知识中枢智能推荐系统升级完成',
              'content': '新系统将基于更先进的算法，为用户提供更精准的知识推荐服务，提升用户体验。',
            },
            {
              'date': '2025-01-05',
              'title': '知识中枢与多家科研机构达成合作',
              'content': '将持续引入高质量的科研成果和学术文献，丰富平台知识资源。',
            },
          ],
        );
      case 'resource':
        return const KnowledgeResourcesSection(
          title: '知识资源',
          resources: [
            {
              'icon': '📚',
              'title': '技术文档库',
              'description': '包含各类技术手册、操作指南、白皮书等专业文档，助力技术学习和应用。',
            },
            {
              'icon': '🔬',
              'title': '科研成果库',
              'description': '汇集最新科研成果和学术论文，推动科研信息的传播和共享。',
            },
            {
              'icon': '📊',
              'title': '行业数据库',
              'description': '提供各行业的统计数据、市场分析、发展趋势等信息，支持决策分析。',
            },
            {
              'icon': '📑',
              'title': '政策法规库',
              'description': '整理各类政策文件、法律法规，帮助用户及时了解相关政策动态。',
            },
            {
              'icon': '💡',
              'title': '案例库',
              'description': '收集各行业创新应用案例，为用户提供实践参考和灵感。',
            },
            {
              'icon': '👥',
              'title': '专家库',
              'description': '汇聚各领域专家资源，提供专业咨询和技术支持服务。',
            },
          ],
        );
      case 'service':
        return const ServiceSection(
          title: '服务介绍',
          services: [
            {
              'title': '知识检索服务',
              'image': '',
              'description': '提供高效精准的知识检索服务，支持多维度检索和智能联想，帮助用户快速找到所需信息。',
              'features': '服务特点：多维度检索、智能联想、精准排序、结果导出',
              'scenarios': '适用场景：研究学习、问题解决、信息收集、决策支持等',
            },
            {
              'title': '知识定制服务',
              'image': '',
              'description': '根据用户特定需求，提供个性化的知识整理和分析服务，形成定制化的知识报告。',
              'features': '服务特点：个性化定制、专业分析、定期更新、多格式输出',
              'scenarios': '适用场景：战略规划、市场分析、技术调研、竞争情报等',
            },
            {
              'title': '知识培训服务',
              'image': '',
              'description': '提供各类知识和技能培训课程，由行业专家授课，提升用户专业能力和知识水平。',
              'features': '服务特点：专业讲师、实战案例、线上线下结合、证书认证',
              'scenarios': '适用场景：员工培训、技能提升、知识更新、职业发展等',
            },
          ],
        );
      case 'policy':
        return const PolicySection(
          title: '政策资讯',
          policies: [
            {
              'title': '《关于促进知识资源开放共享的指导意见》',
              'content':
                  '该意见明确了知识资源开放共享的重要性，提出了一系列支持政策，鼓励各类机构和个人参与知识共享，促进知识传播和创新应用。',
              'link': '查看详情',
            },
            {
              'title': '《数字经济时代知识服务发展规划（2025-2030）》',
              'content':
                  '规划提出了未来五年知识服务产业的发展目标和重点任务，强调要加强知识基础设施建设，提升知识服务能力，推动知识经济发展。',
              'link': '查看详情',
            },
            {
              'title': '《关于支持中小企业获取优质知识资源的实施办法》',
              'content':
                  '办法针对中小企业知识获取难、成本高的问题，提出了一系列扶持措施，包括补贴政策、专项服务等，降低中小企业获取知识资源的门槛。',
              'link': '查看详情',
            },
          ],
        );
      default:
        return _buildDefaultSection(sectionId);
    }
  }

  Widget _buildDefaultSection(String sectionName) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          sectionName == 'construction' ? '建设概况' : '',
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 20),
        const Text(
          '该栏目正在建设中，敬请期待...',
          style: TextStyle(fontSize: 16, color: Color(0xFF666666)),
        ),
      ],
    );
  }
}

// 模型中枢页面
class ModelCenter extends StatefulWidget {
  const ModelCenter({super.key});

  @override
  State<ModelCenter> createState() => _ModelCenterState();
}

class _ModelCenterState extends State<ModelCenter> {
  String activeSection = 'home';

  final List<Map<String, String>> menuItems = [
    {'id': 'home', 'name': '首页'},
    {'id': 'construction', 'name': '建设概况'},
    {'id': 'policy', 'name': '政策资讯'},
    {'id': 'models', 'name': '模型库'},
    {'id': 'tech', 'name': '技术架构'},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            const Header(),
            Container(
              padding: const EdgeInsets.all(20),
              child: Column(
                children: [
                  const Breadcrumb(
                    path: ['服务平台', '模型中枢'],
                    currentPage: '模型中枢',
                  ),
                  const SizedBox(height: 20),
                  LayoutBuilder(
                    builder: (context, constraints) {
                      if (constraints.maxWidth < 768) {
                        return Column(
                          children: [
                            _buildMobileMenu(),
                            const SizedBox(height: 20),
                            _buildContent(),
                          ],
                        );
                      } else {
                        return Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            _buildSidebar(),
                            const SizedBox(width: 30),
                            Expanded(child: _buildContent()),
                          ],
                        );
                      }
                    },
                  ),
                ],
              ),
            ),
            const Footer(
              copyright: '© 2025 创新服务平台模型中枢 版权所有',
              email: 'models@innovationservice.com',
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildSidebar() {
    return Container(
      width: 250,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '模型中枢',
            style: Theme.of(context).textTheme.titleSmall,
          ),
          const SizedBox(height: 20),
          Column(
            children: menuItems.map((item) {
              return Padding(
                padding: const EdgeInsets.only(bottom: 15),
                child: InkWell(
                  onTap: () => setState(() => activeSection = item['id']!),
                  borderRadius: BorderRadius.circular(4),
                  child: Container(
                    padding:
                        const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                    decoration: BoxDecoration(
                      color: activeSection == item['id']
                          ? const Color(0xFFF0F7FF)
                          : Colors.transparent,
                      borderRadius: BorderRadius.circular(4),
                      border: activeSection == item['id']
                          ? const Border(
                              left: BorderSide(
                                  color: Color(0xFF207CCA), width: 4))
                          : null,
                    ),
                    child: Text(
                      item['name']!,
                      style: TextStyle(
                        color: activeSection == item['id']
                            ? const Color(0xFF1E5799)
                            : const Color(0xFF555555),
                        fontWeight: activeSection == item['id']
                            ? FontWeight.bold
                            : FontWeight.normal,
                      ),
                    ),
                  ),
                ),
              );
            }).toList(),
          ),
        ],
      ),
    );
  }

  Widget _buildMobileMenu() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(10),
      child: SingleChildScrollView(
        scrollDirection: Axis.horizontal,
        child: Row(
          children: menuItems.map((item) {
            return Padding(
              padding: const EdgeInsets.symmetric(horizontal: 10),
              child: InkWell(
                onTap: () => setState(() => activeSection = item['id']!),
                borderRadius: BorderRadius.circular(4),
                child: Container(
                  padding:
                      const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                  decoration: BoxDecoration(
                    color: activeSection == item['id']
                        ? const Color(0xFFF0F7FF)
                        : Colors.transparent,
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: Text(
                    item['name']!,
                    style: TextStyle(
                      color: activeSection == item['id']
                          ? const Color(0xFF1E5799)
                          : const Color(0xFF555555),
                      fontWeight: activeSection == item['id']
                          ? FontWeight.bold
                          : FontWeight.normal,
                    ),
                  ),
                ),
              ),
            );
          }).toList(),
        ),
      ),
    );
  }

  Widget _buildContent() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(30),
      child: _getSectionContent(activeSection),
    );
  }

  Widget _getSectionContent(String sectionId) {
    switch (sectionId) {
      case 'home':
        return const HomeSection(
          title: '模型中枢',
          subtitle: '集中管理与应用各类人工智能模型',
          introText:
              '模型中枢是集AI模型管理、训练、部署和应用于一体的综合性平台。我们提供丰富的预训练模型和开发工具，支持用户快速构建、训练和部署各类AI模型，降低AI应用门槛，推动人工智能技术的普及和创新。',
          features: [
            {'title': '模型仓库', 'description': '提供丰富的预训练模型，支持模型版本管理和共享'},
            {'title': '可视化建模', 'description': '提供拖拽式建模工具，降低模型开发门槛'},
            {'title': '分布式训练', 'description': '支持大规模分布式训练，提高模型训练效率'},
            {'title': '一键部署', 'description': '简化模型部署流程，支持多种部署方式'},
            {'title': '模型监控', 'description': '实时监控模型性能，及时发现和解决问题'},
            {'title': '安全可控', 'description': '提供模型加密和访问控制，保障模型安全'},
          ],
          news: [
            {
              'date': '2025-03-20',
              'title': '模型中枢新增100+预训练模型',
              'content': '涵盖自然语言处理、计算机视觉、语音识别等多个领域，满足不同场景的应用需求。',
            },
            {
              'date': '2025-02-15',
              'title': '模型中枢发布自动机器学习平台',
              'content': '该平台可自动完成特征工程、模型选择和参数调优，大幅降低AI应用门槛。',
            },
            {
              'date': '2025-01-20',
              'title': '模型中枢与多家企业达成AI模型共建合作',
              'content': '将共同开发行业专用AI模型，推动AI技术在各行业的深度应用。',
            },
          ],
        );
      case 'models':
        return const ModelLibrarySection(
          title: '模型库',
          models: [
            {
              'title': '自然语言处理模型',
              'description': '包括文本分类、情感分析、机器翻译等多种模型，适用于各类文本处理场景。',
              'tags': ['NLP', '文本处理', '多语言'],
            },
            {
              'title': '计算机视觉模型',
              'description': '涵盖图像分类、目标检测、图像分割等模型，支持多种视觉识别任务。',
              'tags': ['CV', '图像识别', '视频分析'],
            },
            {
              'title': '语音处理模型',
              'description': '包括语音识别、语音合成、声纹识别等模型，适用于语音交互场景。',
              'tags': ['语音', 'ASR', 'TTS'],
            },
            {
              'title': '推荐系统模型',
              'description': '提供个性化推荐算法模型，支持商品推荐、内容推荐等应用场景。',
              'tags': ['推荐', '个性化', '用户画像'],
            },
            {
              'title': '预测分析模型',
              'description': '包括时间序列预测、回归分析等模型，适用于各类预测和分析场景。',
              'tags': ['预测', '分析', '统计'],
            },
            {
              'title': '强化学习模型',
              'description': '提供各类强化学习算法模型，适用于决策优化、控制等复杂场景。',
              'tags': ['强化学习', '决策', '优化'],
            },
          ],
        );
      case 'tech':
        return const TechnologyArchitectureSection(
          title: '技术架构',
          imageUrl: '',
          techItems: [
            {
              'icon': '🧠',
              'title': '模型仓库',
              'description': '集中管理各类AI模型，支持版本控制和元数据管理',
            },
            {
              'icon': '⚙️',
              'title': '训练平台',
              'description': '提供分布式训练环境，支持主流深度学习框架',
            },
            {
              'icon': '🚀',
              'title': '推理服务',
              'description': '高性能模型推理引擎，支持多种部署方式',
            },
            {
              'icon': '📊',
              'title': '监控系统',
              'description': '实时监控模型性能和数据质量',
            },
            {
              'icon': '🔄',
              'title': '持续集成',
              'description': '自动化模型训练、测试和部署流程',
            },
            {
              'icon': '🔒',
              'title': '安全机制',
              'description': '模型加密和访问控制，保障模型安全',
            },
          ],
        );
      default:
        return _buildDefaultSection(sectionId);
    }
  }

  Widget _buildDefaultSection(String sectionName) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          sectionName == 'construction' ? '建设概况' : '政策资讯',
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 20),
        const Text(
          '该栏目正在建设中，敬请期待...',
          style: TextStyle(fontSize: 16, color: Color(0xFF666666)),
        ),
      ],
    );
  }
}

// 场景应用中心页面
class ScenarioApplicationCenter extends StatefulWidget {
  const ScenarioApplicationCenter({super.key});

  @override
  State<ScenarioApplicationCenter> createState() =>
      _ScenarioApplicationCenterState();
}

class _ScenarioApplicationCenterState extends State<ScenarioApplicationCenter> {
  String activeSection = 'home';

  final List<Map<String, String>> menuItems = [
    {'id': 'home', 'name': '首页'},
    {'id': 'construction', 'name': '建设概况'},
    {'id': 'policy', 'name': '政策资讯'},
    {'id': 'activity', 'name': '活动报道'},
    {'id': 'service', 'name': '服务介绍'},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          children: [
            const Header(),
            Container(
              padding: const EdgeInsets.all(20),
              child: Column(
                children: [
                  const Breadcrumb(
                    path: ['服务平台', '场景应用中心'],
                    currentPage: '场景应用中心',
                  ),
                  const SizedBox(height: 20),
                  LayoutBuilder(
                    builder: (context, constraints) {
                      if (constraints.maxWidth < 768) {
                        return Column(
                          children: [
                            _buildMobileMenu(),
                            const SizedBox(height: 20),
                            _buildContent(),
                          ],
                        );
                      } else {
                        return Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            _buildSidebar(),
                            const SizedBox(width: 30),
                            Expanded(child: _buildContent()),
                          ],
                        );
                      }
                    },
                  ),
                ],
              ),
            ),
            const Footer(
              copyright: '© 2025 创新服务平台场景应用中心 版权所有',
              email: 'scenario@innovationservice.com',
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildSidebar() {
    return Container(
      width: 250,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '场景应用中心',
            style: Theme.of(context).textTheme.titleSmall,
          ),
          const SizedBox(height: 20),
          Column(
            children: menuItems.map((item) {
              return Padding(
                padding: const EdgeInsets.only(bottom: 15),
                child: InkWell(
                  onTap: () => setState(() => activeSection = item['id']!),
                  borderRadius: BorderRadius.circular(4),
                  child: Container(
                    padding:
                        const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                    decoration: BoxDecoration(
                      color: activeSection == item['id']
                          ? const Color(0xFFF0F7FF)
                          : Colors.transparent,
                      borderRadius: BorderRadius.circular(4),
                      border: activeSection == item['id']
                          ? const Border(
                              left: BorderSide(
                                  color: Color(0xFF207CCA), width: 4))
                          : null,
                    ),
                    child: Text(
                      item['name']!,
                      style: TextStyle(
                        color: activeSection == item['id']
                            ? const Color(0xFF1E5799)
                            : const Color(0xFF555555),
                        fontWeight: activeSection == item['id']
                            ? FontWeight.bold
                            : FontWeight.normal,
                      ),
                    ),
                  ),
                ),
              );
            }).toList(),
          ),
        ],
      ),
    );
  }

  Widget _buildMobileMenu() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(10),
      child: SingleChildScrollView(
        scrollDirection: Axis.horizontal,
        child: Row(
          children: menuItems.map((item) {
            return Padding(
              padding: const EdgeInsets.symmetric(horizontal: 10),
              child: InkWell(
                onTap: () => setState(() => activeSection = item['id']!),
                borderRadius: BorderRadius.circular(4),
                child: Container(
                  padding:
                      const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                  decoration: BoxDecoration(
                    color: activeSection == item['id']
                        ? const Color(0xFFF0F7FF)
                        : Colors.transparent,
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: Text(
                    item['name']!,
                    style: TextStyle(
                      color: activeSection == item['id']
                          ? const Color(0xFF1E5799)
                          : const Color(0xFF555555),
                      fontWeight: activeSection == item['id']
                          ? FontWeight.bold
                          : FontWeight.normal,
                    ),
                  ),
                ),
              ),
            );
          }).toList(),
        ),
      ),
    );
  }

  Widget _buildContent() {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.05),
            blurRadius: 15,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      padding: const EdgeInsets.all(30),
      child: _getSectionContent(activeSection),
    );
  }

  Widget _getSectionContent(String sectionId) {
    switch (sectionId) {
      case 'home':
        return const HomeSection(
          title: '场景应用中心',
          subtitle: '展示与推广数字化转型应用场景',
          introText:
              '场景应用中心致力于收集、整理和展示各类数字化转型的成功案例和创新应用。通过图文、视频、虚拟现实等多种形式，全方位展示技术在不同行业的应用场景，为用户提供实践参考和灵感，促进技术交流与合作。',
          features: [
            {'title': '多行业覆盖', 'description': '涵盖制造、金融、医疗、教育等多个行业的应用场景'},
            {'title': '多媒体展示', 'description': '采用图文、视频、VR等多种形式展示应用场景'},
            {'title': '深度解析', 'description': '对每个场景进行深度解析，包括技术架构、实施过程等'},
            {'title': '案例库', 'description': '建立完善的案例库，支持按行业、技术等多维度检索'},
            {'title': '互动体验', 'description': '提供交互式体验，增强用户对场景的理解和感受'},
            {'title': '需求对接', 'description': '连接技术供给方和需求方，促进合作与落地'},
          ],
          news: [
            {
              'date': '2025-03-25',
              'title': '场景应用中心新增20个智能制造案例',
              'content': '涵盖智能工厂、工业机器人、数字孪生等多个领域，展示制造业数字化转型成果。',
            },
            {
              'date': '2025-02-10',
              'title': '场景应用中心VR体验区正式上线',
              'content': '用户可通过VR设备沉浸式体验各类应用场景，增强场景理解和感受。',
            },
            {
              'date': '2025-01-15',
              'title': '2024年度数字化转型最佳应用场景评选结果公布',
              'content': '评选出10个年度最佳应用场景，涵盖多个行业，为数字化转型提供参考。',
            },
          ],
        );
      case 'service':
        return const ServiceSection(
          title: '服务介绍',
          services: [
            {
              'title': '场景展示服务',
              'image': '',
              'description':
                  '提供数字化转型场景的数字化展示平台，通过图文、视频、虚拟现实等多种形式，全面展示各类场景应用案例。',
              'features': '服务特点：多维度展示、交互式体验、案例库管理',
              'scenarios': '适用场景：技术应用展示、案例推广、经验分享等',
            },
            {
              'title': '需求对接服务',
              'image': '',
              'description': '连接技术供给方和应用需求方，提供精准的需求匹配和对接服务，促进技术应用落地。',
              'features': '服务特点：智能匹配、专业对接、全程跟踪',
              'scenarios': '适用场景：技术供需对接、解决方案寻找、合作伙伴匹配等',
            },
            {
              'title': '方案验证服务',
              'image': 'https://via.placeholder.com/400x250?text=方案验证',
              'description': '提供数字化转型方案的验证环境和技术支持，帮助企业在实际应用前验证方案的可行性。',
              'features': '服务特点：模拟环境、专家评估、优化建议',
              'scenarios': '适用场景：方案可行性验证、技术选型评估、实施风险控制等',
            },
          ],
        );
      default:
        return _buildDefaultSection(sectionId);
    }
  }

  Widget _buildDefaultSection(String sectionName) {
    String title = '';
    if (sectionName == 'construction')
      title = '建设概况';
    else if (sectionName == 'policy')
      title = '政策资讯';
    else if (sectionName == 'activity') title = '活动报道';

    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 20),
        const Text(
          '该栏目正在建设中，敬请期待...',
          style: TextStyle(fontSize: 16, color: Color(0xFF666666)),
        ),
      ],
    );
  }
}

// 通用组件：头部
class Header extends StatelessWidget {
  const Header({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: const BoxDecoration(
        gradient: LinearGradient(
          colors: [Color(0xFF1E5799), Color(0xFF207CCA)],
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
        ),
        borderRadius: BorderRadius.all(Radius.circular(8)),
        boxShadow: [
          BoxShadow(
            color: Colors.black12,
            blurRadius: 20,
            offset: Offset(0, 5),
          ),
        ],
      ),
      padding: const EdgeInsets.symmetric(vertical: 30),
      child: LayoutBuilder(
        builder: (context, constraints) {
          if (constraints.maxWidth < 768) {
            return Column(
              children: [
                const Text(
                  '创新服务平台',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 24,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                const SizedBox(height: 20),
                _buildNavigationMenu(context),
              ],
            );
          } else {
            return Padding(
              padding: const EdgeInsets.symmetric(horizontal: 30),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  const Text(
                    '创新服务平台',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 24,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  _buildNavigationMenu(context),
                ],
              ),
            );
          }
        },
      ),
    );
  }

  Widget _buildNavigationMenu(BuildContext context) {
    return SingleChildScrollView(
      scrollDirection: Axis.horizontal,
      child: Row(
        children: [
          _buildNavItem(context, '首页', '/'),
          _buildNavItem(context, '智算中心', '/intelligent-calculation'),
          _buildNavItem(context, '知识中枢', '/knowledge'),
          _buildNavItem(context, '模型中枢', '/model'),
          _buildNavItem(context, '场景应用中心', '/scenario'),
          _buildNavItem(context, '联系我们', '#'),
        ],
      ),
    );
  }

  Widget _buildNavItem(BuildContext context, String title, String route) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 12),
      child: InkWell(
        onTap: () {
          if (route != '#') {
            Navigator.pushNamed(context, route);
          }
        },
        child: Text(
          title,
          style: const TextStyle(
            color: Colors.white,
            fontSize: 16,
          ),
        ),
      ),
    );
  }
}

// 通用组件：面包屑导航
class Breadcrumb extends StatelessWidget {
  final List<String>? path;
  final String currentPage;

  const Breadcrumb({
    super.key,
    this.path,
    required this.currentPage,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 15),
      child: Row(
        children: [
          InkWell(
            onTap: () => Navigator.pushNamed(context, '/'),
            child: const Text(
              '首页',
              style: TextStyle(
                color: Color(0xFF1E5799),
                fontSize: 14,
              ),
            ),
          ),
          if (path != null)
            ...path!.asMap().entries.map((entry) {
              int index = entry.key;
              String item = entry.value;
              return Row(
                children: [
                  const Text(
                    ' > ',
                    style: TextStyle(
                      color: Color(0xFF666666),
                      fontSize: 14,
                    ),
                  ),
                  Text(
                    item,
                    style: const TextStyle(
                      color: Color(0xFF1E5799),
                      fontSize: 14,
                    ),
                  ),
                ],
              );
            }),
          Row(
            children: [
              const Text(
                ' > ',
                style: TextStyle(
                  color: Color(0xFF666666),
                  fontSize: 14,
                ),
              ),
              Text(
                currentPage,
                style: const TextStyle(
                  color: Color(0xFF666666),
                  fontSize: 14,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

// 通用组件：首页内容区
class HomeSection extends StatelessWidget {
  final String title;
  final String subtitle;
  final String introText;
  final List<Map<String, String>> features;
  final List<Map<String, String>> news;

  const HomeSection({
    super.key,
    required this.title,
    required this.subtitle,
    required this.introText,
    required this.features,
    required this.news,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 20),
        Text(
          subtitle,
          style: const TextStyle(
            color: Color(0xFF666666),
            fontSize: 16,
          ),
        ),
        const SizedBox(height: 30),
        ImageNetwork(
          'https://via.placeholder.com/1000x300?text=$title',
          width: double.infinity,
          height: 300,
          fit: BoxFit.cover,
        ),
        const SizedBox(height: 30),
        Text(
          introText,
          style: Theme.of(context).textTheme.bodyLarge,
        ),
        const SizedBox(height: 30),
        _buildFeatureGrid(features),
        const SizedBox(height: 30),
        const Text(
          '最新动态',
          style: TextStyle(
            color: Color(0xFF1E5799),
            fontSize: 20,
            fontWeight: FontWeight.bold,
          ),
        ),
        const SizedBox(height: 20),
        _buildNewsList(news),
      ],
    );
  }

  Widget _buildFeatureGrid(List<Map<String, String>> features) {
    return GridView.count(
      shrinkWrap: true,
      physics: const NeverScrollableScrollPhysics(),
      crossAxisCount: MediaQuery.of(Get.context!).size.width < 768 ? 1 : 3,
      crossAxisSpacing: 20,
      mainAxisSpacing: 20,
      childAspectRatio: 1.2,
      children: features.map((feature) {
        return MouseRegion(
          cursor: SystemMouseCursors.click,
          child: AnimatedContainer(
            duration: const Duration(milliseconds: 300),
            decoration: BoxDecoration(
              color: const Color(0xFFF9FBFF),
              borderRadius: BorderRadius.circular(8),
              border: Border.all(color: const Color(0xFFE0E9FF)),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withOpacity(0.1),
                  blurRadius: 15,
                  offset: const Offset(0, 5),
                ),
              ],
            ),
            padding: const EdgeInsets.all(20),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  feature['title']!,
                  style: Theme.of(Get.context!).textTheme.titleSmall,
                ),
                const SizedBox(height: 10),
                Text(
                  feature['description']!,
                  style: Theme.of(Get.context!).textTheme.bodyMedium,
                ),
              ],
            ),
          ),
        );
      }).toList(),
    );
  }

  Widget _buildNewsList(List<Map<String, String>> news) {
    return Column(
      children: news.map((item) {
        return Container(
          padding: const EdgeInsets.symmetric(vertical: 20),
          decoration: const BoxDecoration(
            border: Border(
              bottom: BorderSide(
                color: Color(0xFFE0E9FF),
                // style: BorderStyle.dashed,
              ),
            ),
          ),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              SizedBox(
                width: 100,
                child: Text(
                  item['date']!,
                  style: const TextStyle(
                    color: Color(0xFF207CCA),
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      item['title']!,
                      style: const TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    const SizedBox(height: 5),
                    Text(
                      item['content']!,
                      style: Theme.of(Get.context!).textTheme.bodyMedium,
                    ),
                  ],
                ),
              ),
            ],
          ),
        );
      }).toList(),
    );
  }
}

// 通用组件：服务介绍区
class ServiceSection extends StatelessWidget {
  final String title;
  final List<Map<String, String>> services;

  const ServiceSection({
    super.key,
    required this.title,
    required this.services,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 30),
        Column(
          children: services.map((service) {
            return Container(
              // margin-bottom: 30,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    service['title']!,
                    style: Theme.of(context).textTheme.titleMedium,
                  ),
                  const SizedBox(height: 15),
                  LayoutBuilder(
                    builder: (context, constraints) {
                      if (constraints.maxWidth < 768) {
                        return Column(
                          children: [
                            ImageNetwork(
                              service['image']!,
                              width: double.infinity,
                              height: 200,
                              fit: BoxFit.cover,
                            ),
                            const SizedBox(height: 15),
                            _buildServiceText(service),
                          ],
                        );
                      } else {
                        return Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            ImageNetwork(
                              service['image']!,
                              width: 300,
                              height: 200,
                              fit: BoxFit.cover,
                            ),
                            const SizedBox(width: 20),
                            Expanded(child: _buildServiceText(service)),
                          ],
                        );
                      }
                    },
                  ),
                ],
              ),
            );
          }).toList(),
        ),
      ],
    );
  }

  Widget _buildServiceText(Map<String, String> service) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          service['description']!,
          style: const TextStyle(
            fontSize: 15,
            color: Color(0xFF555555),
            height: 1.8,
          ),
        ),
        const SizedBox(height: 10),
        Text(
          service['features']!,
          style: const TextStyle(
            fontSize: 15,
            color: Color(0xFF555555),
            height: 1.8,
          ),
        ),
        const SizedBox(height: 10),
        Text(
          service['scenarios']!,
          style: const TextStyle(
            fontSize: 15,
            color: Color(0xFF555555),
            height: 1.8,
          ),
        ),
      ],
    );
  }
}

// 通用组件：政策资讯区
class PolicySection extends StatelessWidget {
  final String title;
  final List<Map<String, String>> policies;

  const PolicySection({
    super.key,
    required this.title,
    required this.policies,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 30),
        Column(
          children: policies.map((policy) {
            return Container(
              // margin-bottom: 20,
              padding: const EdgeInsets.all(15),
              decoration: BoxDecoration(
                color: const Color(0xFFF9FBFF),
                borderRadius: BorderRadius.circular(8),
                border: const Border(
                  left: BorderSide(
                    color: Color(0xFF207CCA),
                    width: 4,
                  ),
                ),
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    policy['title']!,
                    style: Theme.of(context).textTheme.titleSmall,
                  ),
                  const SizedBox(height: 10),
                  Text(
                    policy['content']!,
                    style: Theme.of(context).textTheme.bodyMedium,
                  ),
                  const SizedBox(height: 10),
                  InkWell(
                    onTap: () {},
                    child: Text(
                      policy['link']!,
                      style: const TextStyle(
                        color: Color(0xFF207CCA),
                        fontSize: 14,
                      ),
                    ),
                  ),
                ],
              ),
            );
          }).toList(),
        ),
      ],
    );
  }
}

// 通用组件：知识资源区
class KnowledgeResourcesSection extends StatelessWidget {
  final String title;
  final List<Map<String, String>> resources;

  const KnowledgeResourcesSection({
    super.key,
    required this.title,
    required this.resources,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 30),
        GridView.count(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          crossAxisCount: MediaQuery.of(context).size.width < 768 ? 1 : 3,
          crossAxisSpacing: 20,
          mainAxisSpacing: 20,
          childAspectRatio: 1.0,
          children: resources.map((resource) {
            return MouseRegion(
              cursor: SystemMouseCursors.click,
              child: AnimatedContainer(
                duration: const Duration(milliseconds: 300),
                decoration: BoxDecoration(
                  color: const Color(0xFFF9FBFF),
                  borderRadius: BorderRadius.circular(8),
                  border: Border.all(color: const Color(0xFFE0E9FF)),
                  boxShadow: [
                    BoxShadow(
                      color: Colors.black.withOpacity(0.1),
                      blurRadius: 15,
                      offset: const Offset(0, 5),
                    ),
                  ],
                ),
                padding: const EdgeInsets.all(20),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      resource['icon']!,
                      style: const TextStyle(
                          fontSize: 36, color: Color(0xFF207CCA)),
                    ),
                    const SizedBox(height: 15),
                    Text(
                      resource['title']!,
                      style: Theme.of(context).textTheme.titleSmall,
                    ),
                    const SizedBox(height: 10),
                    Text(
                      resource['description']!,
                      style: Theme.of(context).textTheme.bodyMedium,
                    ),
                  ],
                ),
              ),
            );
          }).toList(),
        ),
      ],
    );
  }
}

// 通用组件：模型库
class ModelLibrarySection extends StatelessWidget {
  final String title;
  final List<Map<String, dynamic>> models;

  const ModelLibrarySection({
    super.key,
    required this.title,
    required this.models,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 30),
        GridView.count(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          crossAxisCount: MediaQuery.of(context).size.width < 768 ? 1 : 3,
          crossAxisSpacing: 20,
          mainAxisSpacing: 20,
          childAspectRatio: 1.2,
          children: models.map((model) {
            return MouseRegion(
              cursor: SystemMouseCursors.click,
              child: AnimatedContainer(
                duration: const Duration(milliseconds: 300),
                decoration: BoxDecoration(
                  color: const Color(0xFFF9FBFF),
                  borderRadius: BorderRadius.circular(8),
                  border: Border.all(color: const Color(0xFFE0E9FF)),
                  boxShadow: [
                    BoxShadow(
                      color: Colors.black.withOpacity(0.1),
                      blurRadius: 15,
                      offset: const Offset(0, 5),
                    ),
                  ],
                ),
                padding: const EdgeInsets.all(20),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      model['title']!,
                      style: Theme.of(context).textTheme.titleSmall,
                    ),
                    const SizedBox(height: 10),
                    Text(
                      model['description']!,
                      style: Theme.of(context).textTheme.bodyMedium,
                    ),
                    const SizedBox(height: 10),
                    Wrap(
                      children: (model['tags'] as List<String>).map((tag) {
                        return Container(
                          margin: const EdgeInsets.only(right: 5, top: 5),
                          padding: const EdgeInsets.symmetric(
                              horizontal: 8, vertical: 3),
                          decoration: BoxDecoration(
                            color: const Color(0xFFE0E9FF),
                            borderRadius: BorderRadius.circular(4),
                          ),
                          child: Text(
                            tag,
                            style: const TextStyle(
                              color: Color(0xFF1E5799),
                              fontSize: 12,
                            ),
                          ),
                        );
                      }).toList(),
                    ),
                  ],
                ),
              ),
            );
          }).toList(),
        ),
      ],
    );
  }
}

// 通用组件：技术架构
class TechnologyArchitectureSection extends StatelessWidget {
  final String title;
  final String imageUrl;
  final List<Map<String, String>> techItems;

  const TechnologyArchitectureSection({
    super.key,
    required this.title,
    required this.imageUrl,
    required this.techItems,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 30),
        Container(
          alignment: Alignment.center,
          margin: const EdgeInsets.symmetric(vertical: 40),
          child: ImageNetwork(
            imageUrl,
            fit: BoxFit.contain,
          ),
        ),
        const SizedBox(height: 30),
        GridView.count(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          crossAxisCount: MediaQuery.of(context).size.width < 768 ? 2 : 3,
          crossAxisSpacing: 20,
          mainAxisSpacing: 20,
          childAspectRatio: 1.0,
          children: techItems.map((item) {
            return MouseRegion(
              cursor: SystemMouseCursors.click,
              child: AnimatedContainer(
                duration: const Duration(milliseconds: 300),
                decoration: BoxDecoration(
                  color: const Color(0xFFF9FBFF),
                  borderRadius: BorderRadius.circular(8),
                  border: Border.all(color: const Color(0xFFE0E9FF)),
                  boxShadow: [
                    BoxShadow(
                      color: Colors.black.withOpacity(0.1),
                      blurRadius: 15,
                      offset: const Offset(0, 5),
                    ),
                  ],
                ),
                padding: const EdgeInsets.all(20),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      item['icon']!,
                      style: const TextStyle(
                          fontSize: 36, color: Color(0xFF207CCA)),
                    ),
                    const SizedBox(height: 15),
                    Text(
                      item['title']!,
                      style: const TextStyle(
                        color: Color(0xFF1E5799),
                        fontSize: 16,
                        fontWeight: FontWeight.bold,
                      ),
                      textAlign: TextAlign.center,
                    ),
                    const SizedBox(height: 10),
                    Text(
                      item['description']!,
                      style: Theme.of(context).textTheme.bodyMedium,
                      textAlign: TextAlign.center,
                    ),
                  ],
                ),
              ),
            );
          }).toList(),
        ),
      ],
    );
  }
}

// 通用组件：页脚
class Footer extends StatelessWidget {
  final String copyright;
  final String email;

  const Footer({
    super.key,
    this.copyright = '© 2025 创新服务平台 版权所有',
    this.email = 'contact@innovationservice.com',
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(top: 50),
      padding: const EdgeInsets.all(40),
      decoration: BoxDecoration(
        color: const Color(0xFF1A1A2E),
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        children: [
          SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                _buildFooterLink('关于我们'),
                _buildFooterLink('服务条款'),
                _buildFooterLink('隐私政策'),
                _buildFooterLink('帮助中心'),
                _buildFooterLink('联系我们'),
              ],
            ),
          ),
          const SizedBox(height: 20),
          Text(
            copyright,
            style: const TextStyle(
              color: Colors.white,
              fontSize: 14,
            ),
          ),
          const SizedBox(height: 10),
          Text(
            '地址：XX省XX市XX区XX路XX号 | 服务热线：400-123-4567 | 邮箱：$email',
            style: const TextStyle(
              color: Colors.white,
              fontSize: 14,
            ),
            textAlign: TextAlign.center,
          ),
        ],
      ),
    );
  }

  Widget _buildFooterLink(String text) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: InkWell(
        onTap: () {},
        child: Text(
          text,
          style: const TextStyle(
            color: Color(0xFFA8B2D1),
            fontSize: 14,
          ),
        ),
      ),
    );
  }
}
